package com.project.bean;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.List;

/**
 * @Author(王思翰)
 * @Description(类的描述)订单实体类
 * @Date(创建时间) 2021/7/31 13:55
 */
public class OrderBean {
    /**
     * 订单id
     */
    private int id;
    /**
     * 收货人姓名
     */
    @NotBlank(message = "姓名不能为空")
    private String name;
    /**
     * 收货人地址
     */
    @Pattern(regexp = "[0-9\\u4e00-\\u9fa5]{5,}",
            message = "地址必须为5位以上的汉子或数字")
    private String address;
    /**
     * 收货人电话
     */
    @Pattern(regexp = "1[3578]\\d{9}",
            message = "电话必须为13、15、17、18开始的11位数  ")
    private String phone;
    /**
     * 下单时间
     */
    private LocalDate date=LocalDate.now();
    /**
     * 下单用户
     */
    private UserBean userBean;
    /**
     * 订单总价
     */
    private int money=0;
    /**
     * 订单状态
     */
    private String status="未发货";
    /**
     * 订单详情信息集合
     */
    private List<OrderDetailsBean> list;

    public OrderBean() {
    }

    public OrderBean(String name, String address, String phone,int money, int userId) {
        this.name = name;
        this.address = address;
        this.phone = phone;
        this.money=money;
        this.userBean = new UserBean(userId);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public LocalDate getDate() {
        return date;
    }

    public void setDate(LocalDate date) {
        this.date = date;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public UserBean getUserBean() {
        return userBean;
    }

    public void setUserBean(UserBean userBean) {
        this.userBean = userBean;
    }

    public List<OrderDetailsBean> getList() {
        return list;
    }

    public void setList(List<OrderDetailsBean> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "OrderBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", phone='" + phone + '\'' +
                ", date=" + date +
                ", userBean=" + userBean +
                ", money=" + money +
                ", status='" + status + '\'' +
                ", list=" + list +
                "}\n";
    }
}
